/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package neuronalenetzeelearning.view.controlpanel;

import neuronalenetzeelearning.view.gui.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import neuronalenetzeelearning.model.Graph;
import neuronalenetzeelearning.view.mathoutput.MathOutputComponent;

/**
 *
 * @author Henning Ainödhofer
 * 
 */
public abstract class GraphPanelProperty extends JPanel {
    LinkedList <GraphPanelProperty> panelList = new LinkedList <GraphPanelProperty>();
    LinkedList<String> propertys;
    final int panelWidth = 500;
    final int panelHigh = 725;
    final Color background;
    JButton next;
    JButton previous;
    private JButton helpButton;
    JButton start;
    JButton saveGraphToFile;
    JButton loadGraphFromFile;
    JButton automaticThreshold;
    JButton automaticEgdeWeight;
    JButton automaticInputButton;
    JButton automaticOutputButton;
    JButton pauseStepButton;
    JButton breakStepButton;
    GridBagConstraints constraints;
    GridBagLayout grid ;
    Dimension maxSize;
    JPanel navigation = new JPanel();
    Graph graph = Graph.getExampleGraph();
    MathOutputComponent matrix;
    String path = "";
    int step = 0;

    public GraphPanelProperty(){
        this.constraints = new GridBagConstraints();
        this.grid = new GridBagLayout();
        this.background = Color.WHITE;
        this.setPreferredSize(new Dimension(panelWidth, panelHigh));
        constraints.insets = new Insets(10, 10, 10, 10);

        //Set the look and feel
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        }

        next = new JButton ("Weiter");
        previous = new JButton ("Zurück");
        start = new JButton ("Start");
        helpButton = new JButton("Hilfe");
        loadGraphFromFile = new JButton ("Graph laden");
        saveGraphToFile = new JButton ("Graph speichern");
        this.propertys  = new LinkedList<String>();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        navigation.setBorder(javax.swing.BorderFactory.createTitledBorder("Navigation"));
        navigation.setBackground(background);
         updateActionListener();
    }

    public GraphPanelProperty(Graph graph){
        this.graph = graph;
        this.constraints = new GridBagConstraints();
        this.grid = new GridBagLayout();
        this.background = Color.WHITE;
        this.setPreferredSize(new Dimension(panelWidth, panelHigh));
        constraints.insets = new Insets(10, 10, 10, 10);

        //Set the look and feel
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        }

        next = new JButton ("Weiter");
        previous = new JButton ("Zurück");
        start = new JButton ("Start");
        helpButton = new JButton("Hilfe");
        loadGraphFromFile = new JButton ("Graph laden");
        saveGraphToFile = new JButton ("Graph speichern");
        this.propertys  = new LinkedList<String>();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        navigation.setBorder(javax.swing.BorderFactory.createTitledBorder("Navigation"));
        navigation.setBackground(background);
        this.updateUI();
        this.repaint();
         updateActionListener();
    }

    public void setGraph(Graph graph){
        this.graph = graph;
    }
    public Graph getGraph(){
        return this.graph;
    }
    public void PanelUpdate(){}

    public static void main(String [] args){
        JFrame test = new JFrame();
        test.setPreferredSize(new Dimension(800, 800));
        test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Graph graph = new Graph();
        test.add(new DescriptionGraphPanel(graph.getExampleGraph()));
        test.pack();
        test.setVisible(true);
    }
    public String getPath(){
        return path;
    }
    public int getStep(){
        return step;
    }
    public int getStepWidth(){
        return 0;
    }
    public void updateStepCount(){}
    
    public Vector<Double> getVector(){
        return null;
    }
    public void writePropertysToFile(String prop){}

    public LinkedList<String> getPropertys(){
        return propertys;
    }
    public void setInputVectorPanel(JTable inputVectorTable){}

    public void setTargetVectorPanel(JTable targetVectorTable){}

    public void setOutputVectorPanel(JPanel panel){}

    public JTable getInputTable(){
        return new JTable();
    }

    public JTable getTargetTable(){
        return new JTable();
    }

    public JButton getHelpButton() {
        return helpButton;
    }

    public void updateInputTable(){}
    public void updateOutputTable(){}

    public ActionListener getActionListener(){
        throw new UnsupportedOperationException("Not supported yet. called from "+getClass().getName());
    }

    public final void updateActionListener(){
        helpButton.removeActionListener(helpButton.getAction());
        helpButton.addActionListener(getActionListener());
    }


}
